<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 编写一个方法去掉一个数组的重复元素
        // ['c', 'a', 'z', 'a', 'x', 'a','c']===> ['c', 'a', 'z', 'x']
        function add(arr) {
            var i, j, k = arr.length;
            for (i = 0; i < k; i++) {
                for (j = i + 1; j < k; j++) {
                    if (arr[i] == arr[j]) {
                        arr.splice(j, 1);
                        k--;
                        j--;
                    }
                }
            }
            return arr;
        }console.log(add(['c', 'a', 'z', 'a', 'x', 'a','c']));
    </script>
</body>

</html>